---
title: "Replicate Postgres to Tinybird"
sidebarTitle: "Replicate to Tinybird"
description: "Build real-time analytics dashboards by streaming Postgres data to Tinybird."
---

[Tinybird](https://www.tinybird.co/) is a powerful real-time analytics platform built on ClickHouse. It allows you to ingest, transform, and query large volumes of data with low latency.

Often, you want to stream changes from your Postgres database to Tinybird for real-time analytics. For instance, you might want to analyze order data as it's created or updated in your database:

<Frame>
  <img src="/images/guides/tinybird/send-with-sequin.svg" alt="Tinybird Overview" />
</Frame>

In this guide, you'll learn how to use a Sequin webhook sink to stream Postgres changes to Tinybird in real-time.

## Prerequisites

You are about to create a simple Tinybird data source that receives database changes. You'll set up a webhook sink in Sequin that sends HTTP POST requests to Tinybird's Events API with the payload of database changes.

You'll need the following:

- A [Tinybird account](https://www.tinybird.co/)
- Sequin [installed locally](/quickstart/webhooks)
- A [database](/connect-postgres) connected to Sequin

## Create a Tinybird Data Source

Start by creating a new Data Source in Tinybird that will receive database changes from Sequin.

<Steps titleSize="h3">
  <Step title="Log in to Tinybird">
    Log in to your Tinybird dashboard and navigate to the "Data Sources" tab.
  </Step>

  <Step title="Create new Data Source">
    Click on "Create Data Source".
  </Step>

  <Step title="Select source type">
    Choose "Events API" as the source type.
  </Step>

  <Step title="Copy credentials">
    Copy the endpoint URL and Authorization token. You'll need these for the next steps.
  </Step>
</Steps>

<Check>
You've successfully created a Tinybird Data Source that can receive data via HTTP POST requests.
</Check>

## Create a webhook sink

Create a webhook sink that captures changes to your database and sends them to your Tinybird Data Source:

<Steps titleSize="h3">
    <Step title="Create a new sink">
        Navigate to the "Sinks" tab, click the "Create Sink" button, and select "Webhook Sink".
    </Step>

    <Step title="Select source tables">
        Select the schemas and tables you want to capture changes from (i.e `public.users` or `public`).
    </Step>

    <Step title="Add filters (optional)">
        Add [filters](/reference/filters) to the sink to control which database changes are sent to your webhook endpoint.
    </Step>

    <Step title="Configure backfill">
        You can optionally indicate if you want your webhook endpoint to receive a [backfill](reference/backfills) of all or a portion of the table's existing data. Since you want to replicate the state of the table, select to backfill all data.
    </Step>

    <Step title="Configure message grouping">
        Under "Message grouping", leave the default option selected to ensure events for the same row are sent to your webhook endpoint in order.
    </Step>

    <Step title="Configure sink settings">
        Under "Webhook Sink configuration" leave the defaults:
        - Leave the default value of `30000 ms` for "Request timeout" as this is more than enough time for Tinybird to process the request
        - Leave the default value of `1` for "Batch size" for now.
    </Step>

    <Step title="Configure HTTP endpoint">
        Under "HTTP Endpoint", enter the Tinybird Events API URL you copied earlier. Then click to "Add Encrypted Header" with the key `Authorization` and the value `Bearer YOUR_TINYBIRD_TOKEN`.
    </Step>

    <Step title="Name and create sink">
        Give your sink a name (i.e. `tinybird_sink`) and click "Create Webhook Sink".
    </Step>
</Steps>

<Check>
Your webhook sink is now created and ready to send events to Tinybird.
</Check>

## Test end-to-end
<Steps titleSize="h3">
  <Step title="Create a row in your database">
    For example, insert a row into your table:

    ```sql
    insert into orders (customer_id, amount)
    values (1, 99.99);
    ```
  </Step>

  <Step title="Trace the change in the Sequin dashboard">
    In the Sequin console, open the **Messages** tab on your webhook sink and confirm that a message was delivered.
  </Step>

  <Step title="Confirm the data in Tinybird">
    1. Go to your Tinybird dashboard
    2. Navigate to your Data Source
    3. Run a query to verify the data was received:
    ```sql
    SELECT * FROM your_datasource_name
    LIMIT 10
    ```
  </Step>
</Steps>

<Check>
You've successfully streamed database changes to Tinybird!
</Check>

## Next steps

Build on this foundation:

- Create Pipes in Tinybird to transform your data
- Set up API endpoints in Tinybird to query your data
- Create real-time dashboards with your streaming data
- Configure additional webhook sinks for other tables